package com.newlink.building.login.mvp.presenter

import com.newlink.building.login.mvp.contract.Module_Login_InputEmailContract
import com.newlink.building.login.mvp.model.Module_Login_InputEmailModel
import com.newlink.building.common_base.base.BasePresenter
import com.newlink.building.common_base.ext.ss
import com.newlink.building.common_base.utils.NLog
import com.newlink.building.common_base.utils.logDebug

/**
 * @Author: Jake
 * @Date: 2023-04-06
 * @Description:
 */
class Module_Login_InputEmailPresenter : BasePresenter<Module_Login_InputEmailContract.Model, Module_Login_InputEmailContract.View>(),
    Module_Login_InputEmailContract.Presenter {

    override fun createModel(): Module_Login_InputEmailContract.Model = Module_Login_InputEmailModel()

    override fun sendEmail(email: String, userCategory: Int) {

        mModel?.sendEmail(email, userCategory)?.ss(mModel, mView) { response ->
            logDebug<Module_Login_InputEmailPresenter>("jake.------sendEmail response---------$response")
            NLog.e("sendEmail >>>  : $response")
            response?.also {
                if (it.code == 200) {
                    mView?.sendEmailSuccess()
                } else {
                    mView?.sendEmailFailed(it.data.orEmpty())
                }
            }

        }
    }
}